import torch
from torch.autograd import Variable
import torch.nn as nn
import pandas as pd
from pandas import DataFrame
import matplotlib.pyplot as plt
import numpy as np

if __name__ == '__main__':
    # df1 = pd.read_excel(r'D:\学习常用\A力反馈力反馈\数据处理\python数据处理\量程扩展与漂移减弱\data\201217piaoyi_5Hz.xlsx')
    #
    # print(type(df1))
    # data_raw=df1.values.tolist()
    # data_raw=data_raw[256:len(data_raw)]     #去掉低于滤波器长度的数据
    # #定义漂移基
    # t=2
    # piaoyi_base=np.mean(data_raw[0:100*t])    #漂移基为前ts数据平均
    # #输出漂移信号
    # data_piao=data_raw-piaoyi_base
    # # 构建LSTM预测网络
    # lstm=nn.LSTM(input_size=100, hidden_size=20)
    # x = torch.randn(2, 3, 3)
    #
    #
    #
    # print(x)
    #
    #
    # # plt.figure(1)
    # # plt.subplot(2, 1, 1)  # 图一包含1行2列子图，当前画在第一行第一列图上
    # # plt.plot(data_piao)
    # #
    # # plt.figure(1)
    # plt.subplot(2, 1, 2)  # 当前画在第一行第2列图上
    # plt.plot(data_raw)
    # plt.show()
    df1 = pd.read_excel('data/201217piaoyi_ufcb.xlsx')

    data_raw = df1  # [0:100]    #.values.tolist()
    dataset = data_raw.values
    dataset = dataset.astype('float32')

    time_steps = np.linspace(0, len(dataset), len(dataset))
    data = np.zeros((2, 5, len(dataset)))
    for i in range(5):
        data[0][i] = (4000*np.sin(2 * np.pi * time_steps * 40 * (1 + 0.25 * i))).reshape(1, len(dataset))
        data[1][i] = data[1][i] + dataset.reshape(1, len(dataset))
    plt.figure(1)
    # plt.plot(data[0][0][2:200])
    plt.plot(data[0][0])
    plt.show()